package rwt.server.core;


/**
 * Base class for message handlers. A message handler handles a specific message type. Only messages that come
 * from the outside (e.g. from web clients or the railroad system) require handlers.
 */
public abstract class MessageHandler<T extends BaseMessage>
{
	/**
	 * Handles a message by effecting any required state changes to server-side data objects or the database,
	 * and possibly relaying messages to other clients and/or the railroad system to reflect the change.
	 * <p>
	 * As a rule of thumb, messages arriving from web clients that request a change to a railroad entity do
	 * <i>not</i> manipulate the corresponding server-side entity. Instead, the message is "passed on" to the
	 * railroad system. When the railroad system replies with a message indicating that the change has
	 * actually been made, the entity is updated and all affected clients are informed of the change.
	 */
	public abstract void handle(T message, IConnection source) throws Exception;
}
